#ifndef __GAME_H__
#define __GAME_H__
#include <SDL.h>
#include "TextureManager.h"
#include "GameObject.h"
#include "GameStateMachine.h"
#include "MenuObject.h"

class Game;
typedef Game TheGame;

enum game_states {
    MENU = 0,
    PLAY = 1,
    GAMEOVER = 2
};

class Game {
public:
//    Game(){}
    ~Game(){}

    static Game * Instance(){
        if (s_pInstance == nullptr){
            s_pInstance = new Game();
            return s_pInstance;
        }     
        return s_pInstance;
    }
    bool init(const char * title,
              int xpos, int ypos,
              int width, int height,
              int flags);
    void render();
    void update();
    void handleEvents();
    void clean();
    void setCurrentLevel(int currentLevel);
    GameStateMachine * getStateMachine() {
        return m_pGameStateMachine;
    }

    SDL_Renderer * getRenderer() const { return m_pRenderer; };

    bool is_running() { return m_bRunning;}

    int getGameWidth() const {
        return m_gameWidth;
    }

    int getGameHeight() const {
        return m_gameHeight;
    }

    private:
    Game(){};
    static Game * s_pInstance;

private:
    bool m_bRunning;
    SDL_Window * m_pWindow = nullptr;
    SDL_Renderer * m_pRenderer = nullptr;
    SDL_Texture* m_pTexture;
    
    SDL_Rect m_sourceRectangle;
    SDL_Rect m_destinationRectangle;

    int m_currentFrame;
  //  TextureManager m_textureManager;
    std::vector<GameObject*> m_gameObjects;
    GameObject* m_go;
    GameObject * m_player;
    GameObject * m_enemy;
//    GameObject* m_enemy1;
//    GameObject* m_enemy2;
//    GameObject* m_enemy3;

    // status
    MenuObject * m_pMenuObj1;
    MenuObject * m_pMenuObj2;
    game_states m_currentGameState;    

    // state machine
    GameStateMachine * m_pGameStateMachine;
    int m_gameWidth;
    int m_gameHeight;
    int m_currentLevel;
    int m_bLevelComplete;






    
};


#endif
